import { createRouter, createWebHistory } from 'vue-router'

//导入组件
import LoginVue from '@/views/Login.vue'
import LayoutVue from '@/views/Layout.vue'
import SubjectCommentVue from '@/views/subject/SubjectComment.vue'
import SubjectCategoryVue from '@/views/subject/SubjectCategory.vue'
import SubjectManageVue from '@/views/subject/SubjectManage.vue'
import UserAvatarVue from '@/views/user/UserAvatar.vue'
import UserInfoVue from '@/views/user/UserInfo.vue'
import UserResetPasswordVue from '@/views/user/UserResetPassword.vue'

//定义路由关系
const routes = [
  { path: '/login', component: LoginVue },
  {
    path: '/',
    component: LayoutVue,
    redirect: '/subject/manage',
    children: [
      { path: 'subject/category', component: SubjectCategoryVue }, // 去掉前面的 /
      { path: 'subject/manage', component: SubjectManageVue },
      { path: 'subject/comment', component: SubjectCommentVue },
      { path: 'user/info', component: UserInfoVue },
      { path: 'user/avatar', component: UserAvatarVue },
      { path: 'user/resetPassword', component: UserResetPasswordVue }
    ]
  }
]


//创建路由器
const router = createRouter({
  history: createWebHistory(),
  routes: routes
})

//导出路由
export default router
